package com.ssy.lingxi.pay.config.filter;

import cn.hutool.core.util.CharsetUtil;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CharacterEncodingFilter;

import javax.servlet.Filter;

/**
 * @author jw.chen
 * @version 2.0.0
 * @description GBK编码字符集
 * @date 2021/12/24
 */

@Configuration
public class GBKFilter {
    @Bean
    public FilterRegistrationBean<Filter> myCharsetEncoding(){
        FilterRegistrationBean<Filter> gbkFilter = new FilterRegistrationBean<>();
        CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
        encodingFilter.setEncoding(CharsetUtil.GBK);
        encodingFilter.setForceEncoding(true);
        gbkFilter.setFilter(encodingFilter);
        gbkFilter.addUrlPatterns("/pay/ccb/b2bPay/notify");
        return gbkFilter;
    }
}
